<%@ page language="java" import="java.util.*,java.text.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  </head>
  
  <body>
    This is my JSP page. <br><br>
    <!-- 这是静态注释(客户端可以看见源码)  -->
    <h1><center>Jsp的静态部分</center></h1> <br>
    <h4>小脚本:<%
    	Date today = new Date();
    	SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日hh时mm分ss秒");
    	String strDate = sdf.format(today);
    	int x = 100;	//全局变量
     %></h4>
    <h4>表达式:<%= strDate %></h4>
	<h4>声明:<%!
		static private int y = 200;
		/*
		声明一个方法
		*/
		public double add(double x,double y){
			return x + y;
		}
	 %></h4>
	 <%-- 这是动态注释 --%>
	 <h4>调用上面的方法:<%=add(1.0,2.0) %></h4>
    <script type="text/javascript">
	function display(clock){
    	var now=new Date();   //创建Date对象
    	var year=now.getFullYear(); //获取年份
    	var month=now.getMonth(); //获取月份
    	var date=now.getDate();  //获取日期
    	var day=now.getDay();  //获取星期
    	var hour=now.getHours(); //获取小时
    	var minu=now.getMinutes(); //获取分钟
    	var sec=now.getSeconds(); //获取秒钟
    	month=month+1;
    	var arr_week=new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
    	var week=arr_week[day];  //获取中文的星期
    	var time=year+"年"+month+"月"+date+"日 "+week+" "+hour+":"+minu+":"+sec; //组合系统时间
    	clock.innerHTML="当前时间："+time; //显示系统时间
	}
	window.onload=function(){
    	window.setInterval("display(clock)", 100);
	}
	</script>
		<div id="clock" ></div>
  </body>
</html>
